<?php
defined('IN_TS') or die('Access Denied.');

include 'groupinfo.php';



$title = $strGroup['groupname'];

//小组话题分类
$arrTopicTypes = $new['group']->findAll('group_topic_type',array(
	'groupid'=>$groupid,
));

if(is_array($arrTopicTypes)){
	foreach($arrTopicTypes as $item){
		$arrTopicType[$item['typeid']] = $item;
	}
}


//小组是否需要审核
if($strGroup['isaudit']=='1'){
	//推荐小组
	$arrRecommendGroup = $new['group']->getRecommendGroup('7');
	include template("group_isaudit");

}elseif($strGroup['isopen']=='1' && $isGroupUser=='0'){
	//是否开放访问
	include template("group_isopen");
}else{

	$page = isset($_GET['page']) ? intval($_GET['page']) : 1;

	$lstart = $page*15-15;

	if($typeid > 0){
		$andType = " and `typeid`='$typeid'";
		$url = tsUrl('group','show',array('id'=>$groupid,'typeid'=>$typeid,'page'=>''));
	}else{
		$andType = '';
		$url = tsUrl('group','show',array('id'=>$groupid,'page'=>''));
	}


	$url = tsUrl('group','show',array('id'=>$groupid,'page'=>''));

	$arrArticles = $new['group']->findAll('article',"`groupid`='$groupid'".$andType,'istop desc,addtime desc',null,$lstart.',15');

	if( is_array($arrArticles)){
		foreach($arrArticles as $key=>$item){
			$arrArticle[] = $item;
			$arrArticle[$key]['title'] = tsTitle($item['title']);
			$arrArticle[$key]['content'] = tsDecode($item['content']);
			$arrArticle[$key]['user'] = aac('user')->getOneUser($item['userid']);
			$arrArticle[$key]['typename'] = $arrTopicTypes[$item['typeid']]['typename'];
			$arrArticle[$key]['group'] = aac('group')->getOneGroup($item['groupid']);
			$arrArticle[$key]['abs'] = cututf8 ( t(tsDecode($item ['content'])), 0, 200 );
			if($item['articleid']==$strGroup['articleid']){
				$arrArticle[$key]['isdes'] =1;
			}
			if(!$arrArticle[$key]['abs']){
				$img_path =getTextPhotos(tsDecode($item ['content']));
				if($img_path){
					$arrArticle[$key]['abs']='<img width="100%" src="'.$img_path[0].'">';
				}
			}
		}
	}

	$articleNum = $new['group']->findCount('article',"`groupid`='$groupid' ".$andType);

	$pageUrl = pagination($articleNum, 15, $page, $url);



	//小组会员
	include 'groupuser.php';





	if($page > 1){
		$title = $strGroup['groupname'].' - 第'.$page.'页';
	}


	include template("article");

}